package com.yang.servlet;

import com.yang.pojo.Role;
import com.yang.service.RoleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet("/RoleListServlet")
public class RoleListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        RoleService roleService = new RoleService();
        try {
            int i = 0;
            int j = 0;
            int x = 0;
            request.setAttribute("i",i);
            request.setAttribute("j",j);
            request.setAttribute("x",x);
            ArrayList<Role> allRole = roleService.findAllRole();
            request.setAttribute("allRole",allRole);
            request.getRequestDispatcher("admin_role_list.jsp").forward(request,response);

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
